﻿using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;

namespace ZoeEngine
{
    public class Utility
    {
        #region Unit Conversion Helpers

        private static float _pixelsToMeterRatio = 100;
        private static float _meterToPixelRatio = 1 / _pixelsToMeterRatio;

        public static void SetPixelToMeterRatio(float ratio)
        {
            _pixelsToMeterRatio = ratio;
            _meterToPixelRatio = 1 / _pixelsToMeterRatio;
        }
        public static float ToPixels(float meters)
        {
            return meters * _pixelsToMeterRatio;
        }
        public static float ToPixels(double meters)
        {
            return (float)meters * _pixelsToMeterRatio;
        }
        public static float ToPixels(int meters)
        {
            return (float)meters * _pixelsToMeterRatio;
        }
        public static Vector2 ToPixels(Vector2 meters)
        {
            return meters * _pixelsToMeterRatio;
        }
        public static Vector2 ToPixels(float x, float y)
        {
            return new Vector2(x * _pixelsToMeterRatio, y * _pixelsToMeterRatio);
        }
        public static float ToMeters(float pixels)
        {
            return pixels * _meterToPixelRatio;
        }
        public static float ToMeters(double pixels)
        {
            return (float)pixels * _pixelsToMeterRatio;
        }
        public static float ToMeters(int pixels)
        {
            return pixels * _meterToPixelRatio;
        }
        public static Vector2 ToMeters(Vector2 pixels)
        {
            return pixels * _meterToPixelRatio;
        }
        public static Vector2 ToMeters(float x, float y)
        {
            return new Vector2(x * _meterToPixelRatio, y * _meterToPixelRatio);
        }
        public static Matrix ToMeters(Matrix transMatrix)
        {
            return transMatrix * Matrix.CreateTranslation(_meterToPixelRatio, _meterToPixelRatio, 0);
        }
        #endregion
    }
}
